using System;
using UnityEngine;
using UnityEditor;
using UnityEngine.EventSystems;

namespace Gj
{
    public class TouchCheckHelper : NodeHelper, IPointerEnterHandler, IPointerExitHandler
    {
        public AudioClip clip;
        public SoundType soundType;
        public TouchItemHelper touchItemHelper;

        private bool show;

        public void OnPointerEnter(PointerEventData eventData)
        {
            touchItemHelper.Show();
            touchItemHelper.SetData(_data);
            Emit(UIEvent.Enter);

            if (soundType != SoundType.None)
                Game.single.PlayEFF(soundType);
            else if (clip != null) Game.single.PlayEFF(clip);
        }

        public void OnPointerExit(PointerEventData eventData)
        {
            touchItemHelper.Hide();
            Emit(UIEvent.Exit);

            if (soundType != SoundType.None)
                Game.single.PlayEFF(soundType);
            else if (clip != null) Game.single.PlayEFF(clip);
        }

        protected override void BindData(bool b)
        {
            if (!b)
            {
                touchItemHelper.Hide();
                Emit(UIEvent.Exit);
            }
        }
    }
}